package com.xw.service.xw.ck;

import java.util.List;

import javax.annotation.Resource;

import org.mybatis.spring.SqlSessionTemplate;
import org.springframework.stereotype.Service;

import com.xw.dao.DaoSupport;
import com.xw.entity.Page;
import com.xw.entity.xw.Inandout;
import com.xw.entity.xw.Kc;
import com.xw.util.PageData;



@Service("ckService")
public class CkService {

	@Resource(name = "sqlSessionTemplate")
	private SqlSessionTemplate sqlSessionTemplate;
	@Resource(name = "daoSupport")
	private DaoSupport daoSupport;
	
	/**
	 * 获取药品入库列表
	 * @param pd
	 * @return
	 * @throws Exception 
	 */
	public List<PageData> getList(Page page) throws Exception {
		List<PageData> list=null;
		list=(List<PageData>) daoSupport.findForList("CkMapper.getList_listPage", page);
		return list;
	}
	
	/**
	 * 新增药品入库
	 * @param inandout
	 * @throws Exception 
	 */
	public void add(Inandout inandout) throws Exception {
		daoSupport.save("CkMapper.add",inandout);
	}
	
	
	/**
	 * 新增药品库存
	 * @param inandout
	 * @throws Exception 
	 */
	public void editkc(Kc kc) throws Exception {
		daoSupport.save("CkMapper.editkc",kc);
	}
	
	/**
	 * 根据ypid和mzid获取一条信息 
	 * @param pd
	 * @return
	 * @throws Exception
	 */
	public Kc getKcByMzidAndYpid(PageData pd) throws Exception {
		Kc kc = null;
		kc = (Kc) daoSupport.findForObject("CkMapper.getKcByMzidAndYpid", pd);
		return kc;
	}
	
	
	/**
	 * 删除药品入库信息
	 * @param pd
	 * @throws Exception 
	 */
	public void delete(PageData pd) throws Exception {
		daoSupport.delete("CkMapper.deleteById", pd);
	}
	
	/**
	 * 根据ID获取一条信息 
	 * @param pd
	 * @return
	 * @throws Exception
	 */
	public Inandout getOne(PageData pd) throws Exception {
		Inandout inandout = null;
		inandout = (Inandout) daoSupport.findForObject("CkMapper.getOne", pd);
		return inandout;
	}
	
}
